var userInfo = null;

$.ajax({
    type: 'get',
    url: ajaxUrl("queryUserMessage"),
    async: false,
    success: function(result) {
        // console.log(result);
        if (result.code == 400) {
            location.href = "login.html";
        } else {
            userInfo = result;
        }
    }
});

$(function() {

    $("#user").html(template("userTpl", userInfo));

    $("#logout").on("tap", function() {
        $.ajax({
            type: 'get',
            url: ajaxUrl('logout'),
            success: function(result) {
                if (result.success) {
                    mui.toast("退出登录成功");
                    setTimeout(function() {
                        location.href = "index.html"
                    }, 2000)
                }
            }
        })
    })
})